const mongoose = require('mongoose')
const { generateId } = require('../../utils/index')
const { dbHost } = require('../../conf/index')
mongoose.connect(`mongodb://${dbHost}/music_db`)

const Schema = mongoose.Schema

const commentSchema = new Schema({
  commentNo: {
    type: String,
    default() {
      return generateId('PL')
    }
  },
  // avart:{type:String,require:[true,'用户头像为空']},
  // username:{type:String,require:[true,'用户名为空']},
  userNo: { require: [true, '用户编号为空'], type: String },
  // songNo: { type: String ,default:null},
  songerNo: { type: String,default:null },
  songlistNo: { type: String,default:null },
  content: { type: String, require: [true, '评论为空'] },
  likeNum: { type:Number,default:0},
  commentTime:{type:Date,default(){
    return Date.now()
  }}
})

module.exports = mongoose.model('comment', commentSchema)